#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int prime[] = { 2,3,5,7,11,13,17,19,23,29,31,37 };
int arr[20], vis[20];
int n;

typedef enum
{
	true = 1,
	false = 0
}
bool;

bool is_prime(int num)
{
	for (int i = 0; i < 12; i++)
		if (prime[i] == num)return true;
	return false;
}
void dfs(int cur)
{
	if (cur == n && is_prime(arr[0] + arr[n - 1]))
	{
		for (int i = 0; i < n; i++)
			printf("%d%c", arr[i], i == n - 1 ? '\n' : ' ');
	}
	else for (int i = 2; i <= n; i++)
	{
		if (!vis[i] && is_prime(i + arr[cur - 1]))
		{
			arr[cur] = i;
			vis[i] = 1;
			dfs(cur + 1);
			vis[i] = 0;
		}
	}
}
int main()
{
	int cnt = 0;
	while (scanf("%d", &n) != EOF)
	{
		if (cnt)printf("\n");
		printf("Case %d:\n", ++cnt);
		arr[0] = 1;
		dfs(1);
	}
	return 0;
}